package de.dhbw.karlsruhe.picsim.gui.control;

import de.dhbw.karlsruhe.picsim.gui.VisualisationFactory;
import de.dhbw.karlsruhe.picsim.model.PicTime;
import de.dhbw.karlsruhe.picsim.util.impl.LoggingExecutor;

import javax.swing.*;
import java.awt.event.ActionEvent;

/**
 * Created by IntelliJ IDEA.
 * User: goesen Date:
 * Apr 18, 2010
 * Time: 2:28:22 PM
 */
public final class EncircleAction extends AbstractAction {
    private final VisualisationFactory view;
    private final PicTime picTime;

    public EncircleAction(final VisualisationFactory view, final PicTime picTime) {
        super("Step");
        this.view = view;
        this.picTime = picTime;
    }

    @Override
    public void actionPerformed(final ActionEvent e) {
        setEnabled(false);
        new LoggingExecutor().execute(new Runnable() {
            @Override
            public void run() {
                picTime.circleModel();
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        setEnabled(true);
                        view.rebuild();
                    }
                });

            }
        });


    }

}
